﻿namespace AuchanScan.ViewModels
{
    public class ViewModelLocator
    {
        #region Main

        private static MainViewModel _mainViewModel;

        public static MainViewModel MainViewModelStatic
        {
            get
            {
                if (_mainViewModel == null)
                {
                    _mainViewModel = new MainViewModel();
                }
                return _mainViewModel;
            }

            set { _mainViewModel = value; }
        }

        public MainViewModel MainViewModel
        {
            get { return MainViewModelStatic; }
        }

        #endregion

        #region Sync

        private static SyncViewModel _syncViewModel;

        public static SyncViewModel SyncViewModelStatic
        {
            get
            {
                if (_syncViewModel == null)
                {
                    _syncViewModel = new SyncViewModel();
                }
                return _syncViewModel;
            }

            set { _syncViewModel = value; }
        }

        public SyncViewModel SyncViewModel
        {
            get { return SyncViewModelStatic; }
        }

        #endregion

        #region Pay

        private static PayViewModel _PayViewModel;

        public static PayViewModel PayViewModelStatic
        {
            get
            {
                if (_PayViewModel == null)
                {
                    _PayViewModel = new PayViewModel();
                }
                return _PayViewModel;
            }

            set { _PayViewModel = value; }
        }

        public PayViewModel PayViewModel
        {
            get { return PayViewModelStatic; }
        }

        #endregion

        #region Geo

        private static GeoViewModel _GeoViewModel;

        public static GeoViewModel GeoViewModelStatic
        {
            get
            {
                if (_GeoViewModel == null)
                {
                    _GeoViewModel = new GeoViewModel();
                }
                return _GeoViewModel;
            }

            set { _GeoViewModel = value; }
        }

        public GeoViewModel GeoViewModel
        {
            get { return GeoViewModelStatic; }
        }

        #endregion

        #region MaVoiture

        private static MaVoitureViewModel _MaVoitureViewModel;

        public static MaVoitureViewModel MaVoitureViewModelStatic
        {
            get
            {
                if (_MaVoitureViewModel == null)
                {
                    _MaVoitureViewModel = new MaVoitureViewModel();
                }
                return _MaVoitureViewModel;
            }

            set { _MaVoitureViewModel = value; }
        }

        public MaVoitureViewModel MaVoitureViewModel
        {
            get { return MaVoitureViewModelStatic; }
        }

        #endregion

        #region Trophy

        private static TrophyViewModel _TrophyViewModel;

        public static TrophyViewModel TrophyViewModelStatic
        {
            get
            {
                if (_TrophyViewModel == null)
                {
                    _TrophyViewModel = new TrophyViewModel();
                }
                return _TrophyViewModel;
            }

            set { _TrophyViewModel = value; }
        }

        public TrophyViewModel TrophyViewModel
        {
            get { return TrophyViewModelStatic; }
        }

        #endregion

        #region Promo

        private static PromoViewModel _PromoViewModel;

        public static PromoViewModel PromoViewModelStatic
        {
            get
            {
                if (_PromoViewModel == null)
                {
                    _PromoViewModel = new PromoViewModel();
                }
                return _PromoViewModel;
            }

            set { _PromoViewModel = value; }
        }

        public PromoViewModel PromoViewModel
        {
            get { return PromoViewModelStatic; }
        }

        #endregion

        #region Search

        private static SearchViewModel _SearchViewModel;

        public static SearchViewModel SearchViewModelStatic
        {
            get
            {
                if (_SearchViewModel == null)
                {
                    _SearchViewModel = new SearchViewModel();
                }
                return _SearchViewModel;
            }

            set { _SearchViewModel = value; }
        }

        public SearchViewModel SearchViewModel
        {
            get { return SearchViewModelStatic; }
        }

        #endregion

        internal static bool HasMainViewModel()
        {
            return _mainViewModel != null;
        }
    }
}